<template>
    <div id="lotteryDraw">
        <header>
            <el-button type="primary" class="addBtn" @click="addBtn">添加</el-button>
        </header>
        <main>
            <el-table :data="tableData" border style="width: 100%" stripe>
                <el-table-column prop="id" label="ID"></el-table-column>
                <el-table-column prop="sort" label="顺序"></el-table-column>
                <el-table-column prop="logo" label="图片">
                    <template slot-scope="scope">
                        <el-popover trigger="hover" placement="top">
                            <p>{{scope.row.logo}}</p>
                            <div slot="reference">
                                <img :src=scope.row.logo alt="">
                            </div>
                        </el-popover>
                    </template>
                </el-table-column>
                <el-table-column prop="name" label="名称"></el-table-column>
                <el-table-column prop="sectionMin" label="概率">
                    <template slot-scope="scope">
                        <div slot="reference">
                            <p>{{scope.row.sectionMin}}~{{scope.row.sectionMax}}</p>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column prop="number" label="数量"></el-table-column>
                <el-table-column prop="prizeUpperLimit" label="每日产出上限"></el-table-column>
                <el-table-column prop="alreadyPrizeNum" label="已兑换数量"></el-table-column>
                <el-table-column prop="prizetype" label="奖品类型"></el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button @click="modifyClick(scope.row.id)" type="text" size="small">修改</el-button>
                        <el-button type="text" size="small" @click="removeClick(scope.row.id)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="currPage">
                <el-pagination
                    layout="prev, pager, next"
                    :page-size=pageSize
                    :current-page=currentPage
                    @current-change="handleCurrentChange"
                    :total=total>
                </el-pagination>
            </div>
        </main>
    </div>
</template>
<script>
import Vue from 'vue'
import lotteryDrawModify  from '../modify/lotteryDrawModify'
import lotteryDrawAdd  from '../add/lotteryDrawAdd'
import gDate from '../G_Date/gdate'
import { iframe,addList,ModifyList,RemoteList,DataList,getChannel } from '@/assets/js'
export default {
    data(){
        return {
            currentPage:1,//分页
            tableData:[],
            options:[],//联动菜单
            total:0,
            pageSize:2,
            props:{
                value: 'appid',
                label:"appname"
            },
            handleChangeData:[],//下拉
            TimeData:[]//时间
        }
    },
    methods:{
        addBtn:function(e){//添加
            addList(this,lotteryDrawAdd)
        },
        modifyClick:function(e){//修改
            let obj = {}
            this.tableData.map((item,index)=>{
                if(item.id == e){
                    obj.id = item.id
                    obj.name = item.name
                    obj.logo = item.logo
                    obj.prizetype = item.prizetype
                    obj.number = item.number
                    obj.sectionMin = item.sectionMin
                    obj.sectionMax = item.sectionMax
                    obj.limit = item.prizeUpperLimit
                    obj.sort = item.sort
                    return obj
                }
            })
            ModifyList(this,obj,lotteryDrawModify)
        },
        removeClick:function(e){//删除
            let data = {
                id:e
            }
            RemoteList(this,data,e,"lottery_draw/delPrize")
        },
        handleCurrentChange:function(e){//点击分页
            this.currentPage = e
            let appid = ''
            this.CurrData(e)
        },
        CurrData:function(obj){//分页
            let data = {
                page:obj
            }
            DataList(this,data,'lottery_draw/lotteryDraw')
        }
    },
    mounted:function(){
        this.CurrData()
    }
}
</script>
<style>
    #lotteryDraw header .addBtn{
        position: static;
        width: 100px;
    }
</style>
